{extend name="public/base" /}
{block name="button"}
<button data-target-submit class="layui-btn">保存数据</button>
<button data-target-backup class="layui-btn layui-btn-sm layui-btn-danger">取消编辑</button>
{/block}
{block name="content"}
<form  method="post"  class="layui-form layui-card"  id="TemplateTable"  onsubmit="return false;">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label">模板名称</label>
            <div class="layui-input-block">
                <input name="name" value="{$vo.name|default=''}" required vali-name="模板名称" placeholder="请输入模板名称" class="layui-input" type="text">
                <p class="help-block"><b>必选</b>，请填写模板名称 </p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">模板标识</label>
            <div class="layui-input-block">
                <input name="mark" value="{$vo.mark|default=''}" required vali-name="模板标识" placeholder="请输入模板标识" class="layui-input" type="text">
                <p class="help-block"><b>必选</b>，模板标识具有为唯一性必须是字母或者数字组合 </p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">模板标题</label>
            <div class="layui-input-block">
                <input name="title" value="{$vo.title|default=''}" required vali-name="模板标题" placeholder="请输入模板标题" class="layui-input" type="text">
                <p class="help-block"><b>必选</b>，发送模板标题 </p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="number" name="sort" required vali-name="排序" placeholder="请输入排序" value="{$vo.sort|default='50'}" class="layui-input">
                <p class="help-block">
                    <b>必须是数字排序越小越靠前</b>
                </p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">短信内容</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入模板内容"  class="layui-textarea" name="sms_content">{$vo.sms_content|default=""}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮件内容</label>
            <div class="layui-input-block">
                <script id="container" type="text/plain" style="width:100%;height:500px;">{notempty name="vo.email_content"}{$vo.email_content|htmlspecialchars_decode|raw}{/notempty}</script>
            </div>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
    <div class="layui-form-item text-center">
        <button data-target-submit class="layui-btn">保存数据</button>
        <button data-target-backup class="layui-btn layui-btn-danger" type="button">取消编辑</button>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    window.UEDITOR_HOME_URL = "/static/admin/plugs/ueditor/";
    require(['baidueditor',"jquery"],function (UE,$) {
        var editor = UE.getEditor('container');
        $.menu.highlight_subnav("{:url('index')}")
        $('#TemplateTable').vali(function (form) {
            Object.assign(form, {email_content: UE.getEditor('container').getContent()})
            delete form.editorValue
            $.form.load('{:url()}', form, 'post');
        });
    });
</script>
{/block}
